package com.douqu.game.core.entity.battle;

import com.douqu.game.core.entity.EntityObject;
import com.douqu.game.core.factory.ConstantFactory;

/**
 * 战斗基本信息记录
 * Created by bean on 2017/8/17.
 */
public class BattleDetail extends EntityObject {

    /**
     * 服务器ID,在战斗服务器里生成
     */
    private int serverId;

    /**
     * 战斗ID
     */
    private String id;

    private int createTime;

    private int startTime;

    private int endTime;

    private int winTeam;

    /**
     * 赢家胜利(输家失败)原因-对应E_BattleEnd
     */
    private String endType;

    private int battleType;

    private int battleDetailType;

    private BattleTemp team1Info;

    private BattleTemp team2Info;

    private BattleInitParam initParam;

    public BattleDetail(int serverId, BattleInitParam initParam)
    {
        this.serverId = serverId;
        this.initParam = initParam;

        team1Info = new BattleTemp();
        team2Info = new BattleTemp();
    }

    public int getTeamNo(String playerIndex)
    {
        if(team1Info.getIndexInfo().equals(playerIndex))
            return ConstantFactory.BATTLE_TEAM_1;

        if(team2Info.getIndexInfo().equals(playerIndex))
            return ConstantFactory.BATTLE_TEAM_2;

        return 0;
    }

//    public String getTeam2Index()
//    {
//        if(battleType == SGCommonProto.E_BATTLE_TYPE.BATTLE_TYPE_WORLD_MAP_VALUE)
//            return team2Info.getIndexInfo().substring(0, team2Info.getIndexInfo().lastIndexOf(ConstantFactory.UNDERLINE));
//
//        return team2Info.getIndexInfo();
//    }



    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getBattleType() {
        return battleType;
    }

    public void setBattleType(int battleType) {
        this.battleType = battleType;
    }

    public int getWinTeam() {
        return winTeam;
    }

    public void setWinTeam(int winTeam) {
        this.winTeam = winTeam;
    }


    public int getCreateTime() {
        return createTime;
    }

    public void setCreateTime(int createTime) {
        this.createTime = createTime;
    }

    public int getStartTime() {
        return startTime;
    }

    public void setStartTime(int startTime) {
        this.startTime = startTime;
    }

    public int getEndTime() {
        return endTime;
    }

    public void setEndTime(int endTime) {
        this.endTime = endTime;
    }

    public BattleTemp getTeam1Info() {
        return team1Info;
    }

    public void setTeam1Info(BattleTemp team1Info) {
        this.team1Info = team1Info;
    }

    public BattleTemp getTeam2Info() {
        return team2Info;
    }

    public void setTeam2Info(BattleTemp team2Info) {
        this.team2Info = team2Info;
    }

    public int getServerId() {
        return serverId;
    }

    public void setServerId(int serverId) {
        this.serverId = serverId;
    }

    public int getBattleDetailType() {
        return battleDetailType;
    }

    public void setBattleDetailType(int battleDetailType) {
        this.battleDetailType = battleDetailType;
    }

    public BattleInitParam getInitParam() {
        return initParam;
    }

    public void setInitParam(BattleInitParam initParam) {
        this.initParam = initParam;
    }

    public String getEndType() {
        return endType;
    }

    public void setEndType(String endType) {
        this.endType = endType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof BattleDetail)) return false;

        BattleDetail that = (BattleDetail) o;

        if (!id.equals(that.id)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }


    public String showInfo()
    {
        return "id=" + id + ", [" + team1Info.getIndexInfo() + " -VS- " + team2Info.getIndexInfo() + "]";
    }

    @Override
    public String toString() {
        return "{" +
                "id='" + id + '\'' +
                ", createTime=" + createTime +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", winTeam=" + winTeam +
                ", endType=" + endType +
                ", battleType=" + battleType +
                ", battleDetailType=" + battleDetailType +
                ", team1Info=" + team1Info +
                ", team2Info=" + team2Info +
                ", initParam=" + initParam +
                "} ";
    }
}
